import {createRouter, createWebHistory} from 'vue-router'
import {qiankunWindow} from "vite-plugin-qiankun/dist/helper";
// 子应用路由
const routes = [
    {
        path: '/',
        name: 'SubHome',
        component: () => import('./views/SubHome.vue')
    },
    {
        path: '/page1',
        name: 'SubPage1',
        component: () => import('./views/SubPage1.vue')
    },
    {
        path: '/page2',
        name: 'SubPage2',
        component: () => import('./views/SubPage2.vue')
    }
]

// 获取路由base，如果是qiankun环境使用主应用下发的routerBase
const base = qiankunWindow.__POWERED_BY_QIANKUN__ ? '/sub-app' : (process.env.NODE_ENV === 'development'?'/':'/sub-app')
const router = createRouter({
    history: createWebHistory(base),
    routes
})

export default router
